package com.ys.erp.stage_mall_service.controller;

import com.ys.erp.framework.annotation.CheckEmpLogin;
import com.ys.erp.framework.annotation.RedissonLock;
import com.ys.erp.framework.annotation.ResponseResult;
import com.ys.erp.framework.annotation.StageLoginEmp;
import com.ys.erp.framework.bean.dto.StageEmpDTO;
import com.ys.erp.framework.response.PageDTO;
import com.ys.erp.stage_mall_service.bean.condition.GoodsCondition;
import com.ys.erp.stage_mall_service.bean.vo.GoodsVO;
import com.ys.erp.stage_mall_service.bean.vo.GoodsHeatMapVO;
import com.ys.erp.stage_mall_service.service.GoodsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lwj
 * @date 2025/5/28
 */
@ResponseResult
@RestController
@RequiredArgsConstructor
@RequestMapping("/manage/mall/goods")
@Tag(name = "商品相关接口", description = "商品相关接口")
public class GoodsController {

    private final GoodsService goodsService;

    @PostMapping("/addOrUpGoods")
    @CheckEmpLogin
    @Operation(description = "添加或更新商品")
    @RedissonLock(key = "#con.goodsName")
    public void addOrUpGoods(@RequestBody @Valid GoodsCondition.AddOrUpGoodsCon con,
                             @StageLoginEmp StageEmpDTO empDTO) {
        goodsService.addOrUpGoods(empDTO, con);
    }

    @GetMapping("/copyGoods")
    @CheckEmpLogin
    @Operation(description = "复制商品")
    @RedissonLock(key = "#id")
    public void copyGoods(@RequestParam("id") Long id,
                             @StageLoginEmp StageEmpDTO empDTO) {
        goodsService.copyGoods(empDTO, id);
    }

    @PostMapping("/pageGoods")
    @CheckEmpLogin
    @Operation(description = "商品列表")
    public PageDTO<GoodsVO> pageGoods(@RequestBody GoodsCondition.PageGoodsCon con,
                                      @StageLoginEmp StageEmpDTO empDTO) {
        return goodsService.pageGoods(con);
    }

//    @PostMapping("/goodHeatMap")
//    @CheckEmpLogin
//    @Operation(description = "商品热力图")
//    public  List<GoodsHeatMapVO> goodHeatMap (@StageLoginEmp StageEmpDTO empDTO) {
//        return goodsService.goodHeatMap(empDTO);
//    }

}
